package com.olymtech.jbricks.dingtalk.message.delivery.request;

import com.dingtalk.api.request.OapiChatSendRequest;
import com.dingtalk.api.request.OapiMessageCorpconversationAsyncsendV2Request;
import com.olymtech.jbricks.dingtalk.message.Message;
import com.olymtech.jbricks.dingtalk.message.delivery.ChatMessageDelivery;
import com.olymtech.jbricks.dingtalk.message.delivery.MessageDelivery;
import com.olymtech.jbricks.dingtalk.message.delivery.msg.ChatMessageFactory;
import com.olymtech.jbricks.dingtalk.message.delivery.msg.MessageFactory;
import com.olymtech.jbricks.dingtalk.message.delivery.msg.WorkMessageFactory;
import com.taobao.api.BaseTaobaoRequest;

/**
 * @author haoting.wang
 * @date 2020/12/10 4:33 下午
 **/
public class ChatTaobaoRequest {

    private ChatMessageDelivery messageDelivery;

    private Message message;

    public ChatTaobaoRequest(MessageDelivery messageDelivery, Message message) {
        this.messageDelivery = (ChatMessageDelivery) messageDelivery;
        this.message = message;
    }

    public BaseTaobaoRequest build() {

        OapiChatSendRequest request = new OapiChatSendRequest();
        request.setChatid(messageDelivery.getChatid());

        MessageFactory messageFactory = new ChatMessageFactory();

        request.setMsg((OapiChatSendRequest.Msg) messageFactory.conversationMessage(message));


        return request;
    }
}
